﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SF.WebClient.Controllers
{
    public class CachePoolController : BasicController
    {
        private static List<dynamic> comboboxData = new List<dynamic>();

        static CachePoolController() 
        {
            comboboxData.Add(new { value = "1", text = "蜘蛛侠" });
            comboboxData.Add(new { value = "2", text = "蝙蝠侠" });
            comboboxData.Add(new { value = "3", text = "钢铁侠" });
            comboboxData.Add(new { value = "4", text = "神奇四侠" });
            comboboxData.Add(new { value = "5", text = "接盘侠" });
        }

        /// <summary>
        /// 获取combobox的数据源
        /// </summary>
        /// <returns></returns>
        public JsonResult getComboboxData() 
        {
            return Json(comboboxData);
        }

        /// <summary>
        /// 改变combobox的数据源
        /// </summary>
        /// <returns></returns>
        public JsonResult changeComboboxData() 
        {
            comboboxData.Add(new { value = "6", text = "绿箭侠" });
            return Json(comboboxData);
        }

        /// <summary>
        /// 重置combobox的数据源
        /// </summary>
        /// <returns></returns>
        public JsonResult resetComboboxData()
        {
            comboboxData.RemoveAt(comboboxData.Count - 1);
            return Json(comboboxData);
        }

        #region supportDataCache 支持数据缓存

        public ViewResult CachePoolDemo()
        {
            return View();
        }

        public PartialViewResult CachePoolSource()
        {
            return PartialView();
        }

        public void ViewCachePoolSource()
        {
            this.WriteSourceCode("/Scripts/jquery-easyui-extensions/cachePool/jeasyui.extensions.cachePool.js");
        }

        public PartialViewResult CachePoolExplain()
        {
            return PartialView();
        }

        #endregion
    }
}